<template>
	<view class="wrap">
		<baseForm :column.sync="column" @submitFun="submitFun" :button="button"></baseForm>
		<progressBox :auditVos="auditVos" dictcode="dict_audit_status"></progressBox>
		<view class="buttons" v-if="getApprovalShow('applyStatus')">
			<button size="mini" class="middleButton" @click="pass('报销', itemData)">通过</button>
			<button size="mini" class="middleButton" @click="unpass('报销', itemData)">不通过</button>
		</view>
	</view>
</template>

<script>
import baseForm from '@/wxcomponents/form/form.vue';
import login from '@/libs/login.js';
import progressBox from '@/wxcomponents/commonLayout/progressLevel.vue';
import userMixins from '@/libs/userMixins.js'
import approvalMixins from '@/libs/approvalMixins.js'
import formMixins from '@/libs/formMixins.js'
export default {
	mixins: [userMixins, approvalMixins, formMixins],
	data() {
		return {
			itemData: '',
			button: {
				hide: true
			},
			auditVos: '',
			column: [
				{
					label: '报销名称', //输入框title
					name: 'reimburseName', //传值类型
					type: 'normalInput', //输入框类型
					disabled: true, //是否禁用
					required: true, //是否必须填写
					value: '' //输入框的值
				},
				{
					label: '报销金额',
					name: 'reimburseAmount',
					type: 'normalInput',
					required: true,
					disabled: true,
					value: ''
				},
				{
					label: '备注',
					name: 'remark',
					type: 'normalInput',
					disabled: true,
					required: false,
					value: '',
					text: '无'
				},
				{
					label: '附件(发票收据)',
					type: 'upload',
					url: '/stu/common/uploadFile',
					docFileId: '',
					docFileUrl: '',
					docFileName: '',
					attachmentVoListStr: '',
					limitSize: 3,
					disabled: true
				}
			]
		};
	},
	async onLoad(option) {
		this.itemData = JSON.parse(option.data);
		this.getDetail(this.itemData.id);
	},
	methods: {
		async getDetail(id) {
			let self = this;
			let caseMap = [
				{
					condition() {	// 详情
						return self.itemData.detailType == 'detail'
					},
					async func() {
						let resp = await self.$http.get({
							url: `/oa/reimburseApply/detail?id=${id}`
						});
						self.assignFormDataToViewModel(resp.result, self.column);
						self.auditVos = resp.result.audits;
					}
				},
				{
					condition() {	// 审批
						return self.itemData.detailType == 'approval'
					},
					async func() {
						let resp = await self.$http.get({
							url: `/oa/reimburse/detail?id=${id}`
						});
						self.assignFormDataToViewModel(resp.result, self.column);
						self.auditVos = resp.result.audits;
					}
				},
			]
			let findOne = caseMap.filter(item => {
				return item.condition()
			})[0]
			if (!findOne) {
				alert(`getDetail方法出错`)
			}
			findOne.func();
		},
	},
	components: {
		baseForm,
		progressBox
	}
};
</script>

<style lang="scss" scoped>
page {
	min-height: 100%;
}
.wrap {
	height: 100%;
}
.buttons {
	width: 650upx;
	margin: 20upx auto;
	display: flex;
	justify-content: space-between;
}
</style>
